package com.sngamelib.topdownshooter;

import org.andengine.engine.camera.Camera;
import org.andengine.engine.camera.hud.HUD;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.FillResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background;
import org.andengine.entity.sprite.Sprite;
import org.andengine.entity.text.Text;
import org.andengine.entity.text.TextOptions;
import org.andengine.opengl.texture.TextureOptions;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.ui.activity.SimpleBaseGameActivity;
import org.andengine.util.HorizontalAlign;

public class MainGameActivity extends SimpleBaseGameActivity
{
	private Camera camera;
	private static final int CAMERA_WIDTH = 800;
	private static final int CAMERA_HEIGHT = 480;
	
	//texture crap
	private BitmapTextureAtlas yourTexture;
	private ITextureRegion yourTextureRegion;
	
	private Text scoreText;
    private HUD gameHUD;
	
    @Override
    public EngineOptions onCreateEngineOptions()
    {
    	camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
        EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, 
        new FillResolutionPolicy(), camera);
        return engineOptions;
    }

    @Override
    protected void onCreateResources()
    {
    	loadGraphics();
    }

    @Override
    protected Scene onCreateScene()
    {
    	Scene scene = new Scene();
        scene.setBackground(new Background(0.09804f, 0.6274f, 0.8784f));
        this.mEngine.getTextureManager().loadTexture(yourTexture);
        Sprite test = new Sprite(400, 215, yourTextureRegion, new VertexBufferObjectManager());
        scene.attachChild(test);
        return scene;
    }
    
    private void loadGraphics()
    {
    	BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
    	//String test = BitmapTextureAtlasTextureRegionFactory.getAssetBasePath();
    	//Text myText = new Text(20, 420, )
    	//System.console().writer().print(BitmapTextureAtlasTextureRegionFactory.getAssetBasePath());
        yourTexture = new BitmapTextureAtlas(getTextureManager(), 256, 256, TextureOptions.DEFAULT);
        yourTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(yourTexture, this, "ship_alpha00.gif", 0, 0);
        yourTexture.load(); 
    }

//    private void createHUD()
//    {
//        gameHUD = new HUD();
//        
//        // CREATE SCORE TEXT
//        scoreText = new Text(20, 420, new IFont(), "Score: 0123456789", new TextOptions(HorizontalAlign.LEFT), vbom);
//        scoreText.setSkewCenter(0, 0);    
//        scoreText.setText("Score: 0");
//        gameHUD.attachChild(scoreText);
//        
//        camera.setHUD(gameHUD);
//    }
}